package com.springlearn.springbootlearn.controller;

import com.springlearn.springbootlearn.common.Result;
import com.springlearn.springbootlearn.exception.CustomException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/welcome")
public class WelcomeController {

    @RequestMapping("/index")
    public Result index(){
        System.out.println("欢迎访问index控制器");
        if (2 > 1){
            throw new CustomException(500,"账号已冻结");
        }
        return Result.success("hello,毛毛");
    }

    @RequestMapping("/list")
    public Result list(){
        Map<String,Object> map = new HashMap<>();
        map.put("name","程序员毛毛");
        map.put("phone","15097679443");

        return Result.success(map);
    }
}
